import 'package:demo202112/CustomNaviAnimation/custom_animation_page.dart';
import 'package:demo202112/MultiThreading/async_contoller.dart';
import 'package:demo202112/MyAnimation/wy_animation_widget.dart';
import 'package:demo202112/MyAnimation/wy_curvedAnimation.dart';
import 'package:demo202112/MyAnimation/wy_photo_hero.dart';
import 'package:demo202112/MyAnimation/wy_tween.dart';
import 'package:demo202112/MyNavigator/wy_navigator.dart';
import 'package:demo202112/MyNavigator/wy_pagea.dart';
import 'package:demo202112/ScaffoldLayout/drawer_scaffold.dart';
import 'package:demo202112/blue/blue_page.dart';
import 'package:demo202112/photo_app.dart';
import 'package:demo202112/stateful_group_page.dart';
import 'package:demo202112/wy_AnimatedOpacity.dart';
import 'package:demo202112/wy_align.dart';
import 'package:demo202112/wy_animationlist.dart';
import 'package:demo202112/wy_appBar.dart';
import 'package:demo202112/wy_button.dart';
import 'package:demo202112/wy_buttons.dart';
import 'package:demo202112/wy_chip.dart';
import 'package:demo202112/wy_constrained.dart';
import 'package:demo202112/wy_constrainers.dart';
import 'package:demo202112/wy_constraints.dart';
import 'package:demo202112/wy_container.dart';
import 'package:demo202112/wy_custompaint.dart';
import 'package:demo202112/wy_customscrollview.dart';
import 'package:demo202112/wy_datatable.dart';
import 'package:demo202112/wy_daypicker.dart';
import 'package:demo202112/wy_dialog.dart';
import 'package:demo202112/wy_draggable.dart';
import 'package:demo202112/wy_element.dart';
import 'package:demo202112/wy_flex.dart';
import 'package:demo202112/wy_flow.dart';
import 'package:demo202112/wy_form.dart';
import 'package:demo202112/wy_futureBuilder.dart';
import 'package:demo202112/wy_gridview.dart';
import 'package:demo202112/wy_inherited_widget.dart';
import 'package:demo202112/wy_inkwell.dart';
import 'package:demo202112/wy_layout_builder.dart';
import 'package:demo202112/wy_listview.dart';
import 'package:demo202112/wy_materialapp.dart';
import 'package:demo202112/wy_mediaquery.dart';
import 'package:demo202112/wy_nestedscrollview.dart';
import 'package:demo202112/wy_notification.dart';
import 'package:demo202112/wy_pageview.dart';
import 'package:demo202112/wy_pageview1.dart';
import 'package:demo202112/wy_reorderableListview.dart';
import 'package:demo202112/wy_row_colunm.dart';
import 'package:demo202112/wy_scrollcontroller.dart';
import 'package:demo202112/wy_scrollcontroller2.dart';
import 'package:demo202112/wy_shows.dart';
import 'package:demo202112/wy_snackBar.dart';
import 'package:demo202112/wy_stack.dart';
import 'package:demo202112/wy_tabbar_view.dart';
import 'package:demo202112/wy_theme.dart';
import 'package:demo202112/wy_transform.dart';
import 'package:demo202112/wy_widget_catche.dart';
import 'package:demo202112/wy_willpopscope.dart';
import 'package:demo202112/wy_wrap.dart';
import 'package:flutter/material.dart';
import 'package:demo202112/wy_clip.dart';

import 'MyAnimation/wy_animatedOpacity_page.dart';
import 'MyAnimation/wy_excesssive_animation_page.dart';
import 'MyAnimation/wy_hero_animation_page.dart';
import 'MyAnimation/wy_rotation_animation_page.dart';
import 'MyAnimation/wy_staggered_animation_page.dart';
import 'MyAnimation/wy_stepTween_animation.dart';
import 'MyAnimation/wy_switcher_animation.dart';
import 'MyAnimation/wy_throw_animation_page.dart';
import 'MyNaviPage/my_home_page.dart';
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    // return getMaterialApp();

    return MaterialApp(
      title: '测试效果',
      theme: ThemeData(primaryColor: Colors.blue),
      home: MyHomePage(
        title: "首页",
      ),
      routes: <String, WidgetBuilder>{
        'less': (BuildContext context) => StatefullGroup(),
        'photo': (BuildContext context) => PhotoAppDemo(),
      },


    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver{
  int _counter = 0;
  int _currentindex = 0;
  double moveX = 0;
  double moveY = 0;


  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    // WidgetsBinding.instance?.addObserver(self);
  }
  @override
  Widget build(BuildContext context) {

    return Scaffold(

      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Container(
        padding: EdgeInsets.all(30),
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: ListView(
          padding: EdgeInsets.only(bottom: 60),
//          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return BluePage();
                return WyDataTable();
              }));
            }, child: Text("蓝牙")),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return WyDataTable();
                return WyDataTable();
              }));
            }, child: Text("DataTable")),
            

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return WySnackBarPage();
              }));
            }, child: Text('底部消息提醒')),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return WyConstraints();
              }));
            }, child: Text('父子约束')),
            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return WyAppBarPage();
              }));
            }, child: Text('AppBar')),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return asyncController();
              }));
            }, child: Text('async')),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return MyDrawer();
              }));
            }, child: Text('抽屉效果')),
            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return HomeCustomPage();
              }));
            }, child: Text('CustomElement')),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return MyNotificationPage();
              }));
            }, child: Text('Notification')),


            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return WyThemePage();
              }));
            }, child: Text('Theme')),

            ElevatedButton(onPressed: (){
              Navigator.push(context, MaterialPageRoute(builder: (_){
                return MyInheritedWidget();
              }));
            }, child: Text('InheritedWidget')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyTransformPage()));
            }, child: Text('Transform')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> WyLayoutBuilderPage()));
            }, child: Text('LaoutBuider')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> WyAlignPage()));
            }, child: Text('对齐与相对定位')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyFlowPage()));
            }, child: Text('流式布局Flow')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyFlexPage()));
            }, child: Text('弹性布局Flex')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyConstrainers()));
            }, child: Text('布局约束组件')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyGridViewPage()));
            }, child: Text('GridView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyAnimatedList()));
            }, child: Text('AnimatedList')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyScrollcontroller2()));
            }, child: Text('滚动监听控制2')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyScrollController()));
            }, child: Text('滚动监听控制')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyListViewPage()));
            }, child: Text('ListView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyTabbarView1()));
            }, child: Text('TabBarView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> WyPageViewAlive()));
            }, child: Text('页面缓存')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyExcessiveAnimation()));
            }, child: Text('组件过渡动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> AnimatedSwitcherCounterRoute()));
            }, child: Text('组件切换动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> MyCustomAmniatonPageA()));
            }, child: Text('自定义路由切换动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> ThrowAnimationPage()));
            }, child: Text('物理动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> StaggeredAnimationPage()));
            }, child: Text('交织动画')),


            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> RotationAnimationPage()));
            }, child: Text('显式动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> OpacityChangePage()));
            }, child: Text('隐式动画')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> HeroListPage()));
            }, child: Text('HeroListPage新闻')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=> HeroAnimationRoute()));
            }, child: Text('HeroAnimationRoute')),
            
            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const MyAnimationWidget()));
            }, child: Text('AnimationWidget')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const StepTweenPage()));
            }, child: Text('StepTweenPage')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const MyTween()));
            }, child: Text('Tween')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const MyCurvedAnimation()));
            }, child: Text('CurvedAnimation')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>const MyPaint()));
            }, child: Text('CustomPain')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>PageA()));
            }, child: Text('Navigator局部跳转')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyNavigator()));
            }, child: Text('Navigator导航')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyHomePage1(title: 'Navigator', key: Key('Navigator'),)));
            }, child: Text('WillPopScope')),

            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            Chip(
              label: Text("ddd"),
              avatar: Icon(Icons.people),
            ),
            BackButton(),
            CloseButton(),
            Card(
              child: Container(
                padding: EdgeInsets.all(10),
                child: Text('fff的给付对价费劲大家费劲大家发电机房的解放军'),
              ),
              color: Colors.blue,
              elevation: 5,
              margin: EdgeInsets.all(10),
            ),
            ElevatedButton(onPressed: () {
              Navigator.pushNamed(context, 'less1');

            }, child: Text('不存在的路由')),
            ElevatedButton(onPressed: () {
              Navigator.pushNamed(context, 'less');

            }, child: Text('存在的路由')),
            ElevatedButton(
                onPressed: () {
                  Navigator.pushNamed(context, 'photo');
                },
                child: Text("拍照")),
            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyContainer()));

            }, child: Text('Container')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyRowColumn()));

            }, child: Text('Row Column')),
            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyWrap()));

            }, child: Text('Wrap')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyAnimatedOpacity()));

            }, child: Text('WyAnimatedOpacity')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyFutureBuilder()));

            }, child: Text('FutureBuilder')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyInkwell()));

            }, child: Text('Inkwell')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyPageView()));

            }, child: Text('PageView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyPageView1()));

            }, child: Text('PageView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyDialog()));

            }, child: Text('Dialog')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyDataTable()));

            }, child: Text('DataTable')),
            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyConstrained()));

            }, child: Text('约束容器')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyStack()));

            }, child: Text('Stack,positioned')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyReorderableListView()));

            }, child: Text('ReorderableListView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyDraggable()));

            }, child: Text('Draggable拖动组件')),


            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyClip()));

            }, child: Text('Clips各种图像裁剪')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyFormPage()));

            }, child: Text('Form表单')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyButtoms()));

            }, child: Text('内置各种buttons')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyShows()));

            }, child: Text('内置各种shows')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyMediaQuery()));

            }, child: Text('MediaQuery')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyCustomScrollView()));
            }, child: Text('CustomScrollView')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>WyNestedScrollView()));
            }, child: Text('NestedScrollView')),
            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyDayPicker()));
            }, child: Text('日期插件')),

            ElevatedButton(onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context)=>MyChips()));
            }, child: Text('Chip')),

          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Navigator.pushNamed(context, 'less');
          _ontapshowBottomSheet();
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  _ontapshowBottomSheet(){
    showBottomSheet(

        context: context,
        builder: (BuildContext context){
          return Container(
            height: 200,
            color: Colors.lightBlueAccent,
          );
        });
  }

//  生命周期变化时回调
//  resumed:应用可见并可响应用户操作,app进入前台
//  inactive:用户可见，但不可响应用户操作，比如来了个电话,前后台切换的过渡状态
//  paused:已经暂停了，用户不可见、不可操作，app进入后台
//  suspending：应用被挂起，此状态IOS永远不会回调
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    // TODO: implement didChangeAppLifecycleState
    super.didChangeAppLifecycleState(state);
    print("didChangeAppLifecycleState: $state");

  }
  //当前系统改变了一些访问性活动的回调
  @override
  void didChangeAccessibilityFeatures() {
    // TODO: implement didChangeAccessibilityFeatures
    super.didChangeAccessibilityFeatures();
    print("didChangeAccessibilityFeatures");
  }
  //低内存回调
  @override
  void didHaveMemoryPressure() {
    // TODO: implement didHaveMemoryPressure
    super.didHaveMemoryPressure();
    print("object");
  }
}
